﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;

namespace frost
{
    class Spelare
    {
        public int x;
        public int y;
        Random rand1 = new Random();
        Rectangle figur = new Rectangle(0, 0, Konst.tileWidth, Konst.tileHeight);

        public Spelare()
        {
            x = rand1.Next(20);
	        y = rand1.Next(20);
            figur.X = Konst.biasX + this.x * Konst.tileWidth;
            figur.Y = Konst.biasY + this.y * Konst.tileHeight;
        }

        public void move(int xSteg, int ySteg)
        {

	        //Uppdaterar xy koordinaterna
	        this.x += xSteg;
	        if( this.x < 0 )
		        this.x = 0;
	        if( this.x > Konst.matrixWidth-1 )
		        this.x = Konst.matrixWidth-1;

	        this.y += ySteg;
	        if( this.y < 0 )
		        this.y = 0;
	        if( this.y > Konst.matrixHeight-1 )
		        this.y = Konst.matrixHeight-1;

            figur.X = Konst.biasX + this.x * Konst.tileWidth;
            figur.Y = Konst.biasY + this.y * Konst.tileHeight;
        } 

        //Ritar ut nya spelar platsen
        public void draw(Graphics g)
        {
            g.FillRectangle(new SolidBrush(Color.Blue), figur);
        }

        public int getX()
        {
            return this.x;
        }
        public int getY()
        {
            return this.y;
        }
    }
}
